﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace dbiparser
{
    public class checkOnline
    {
        private string _wsurl;
        public string WSURL { get { return _wsurl; } set { _wsurl = value; } }
        private string _wslogin;
        public string WSLOGIN { get { return _wslogin; } set { _wslogin = value; } }
        private string _wssenha;
        public string WSSENHA { get { return _wssenha; } set { _wssenha = value; } }

        private string xmlretorno;
        public string XMLRETORNO { get { return xmlretorno; } }
        private string xmlretornoSemPagina;
        public string XMLRETORNOSEMPAGINA { get { return xmlretornoSemPagina; } }

        public checkOnline()
        { 
        }
        public checkOnline(string url, string login, string senha)
        {
            _wsurl = url;
            _wslogin = login;
            _wssenha = senha;
            // ignorar ssl
            System.Net.ServicePointManager.ServerCertificateValidationCallback +=
    delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                            System.Security.Cryptography.X509Certificates.X509Chain chain,
                            System.Net.Security.SslPolicyErrors sslPolicyErrors)
            {
                return true; // **** Always accept

            };
            // fim ignorar
        }

        public string consultar()
        {
            IDBIwsservice ws = new IDBIwsservice();
            //dbilb.dbiws ws = new dbilb.dbiws();
            //br.com.smartscore.ws3.IDBIwsservice ws = new br.com.smartscore.ws3.IDBIwsservice();
            //string u = ws.Url.ToString();
            ws.Url = _wsurl;
            ws.Timeout = 30000;

            

            xmlretorno = ws.CheckOnLine().ToString();

            return xmlretorno;

        }
    
    }
}
